The present disclosure relates to a communication device, a communication method, a program, and a communication system, and specifically, to a communication device, a communication method, a program, and a communication system preferably used in noncontact communication.
Currently, noncontact communication IC card communication technologies represented by FeliCa (registered trademark) are widely used for electronic money, tickets for transportation, etc.
FIG. 1 shows an example of an existing configuration of a noncontact communication system for realizing noncontact communication.
The noncontact communication system 1 includes a reader/writer (hereinafter, abbreviated as “R/W”) 2 and a noncontact communication IC card (hereinafter, simply referred to as “IC card”) 10. In the noncontact communication system 1, a user of the IC card 10 holds the IC card 10 over the R/W 2, and thereby, drive power is generated in the IC card 10 based on electromagnetic wave from the R/W 2 and data communication is performed.
The IC card 10 includes an antenna 11 for transmission and reception of electromagnetic wave, a receiving unit 12 that receives a command from the R/W 2, a command processing unit 13 that performs processing in response to the command, an updating unit 14 that updates data recorded in a nonvolatile memory 16 according to a result of the command processing unit 13, a selector 15 that indicates an enabled area of the nonvolatile memory 16, the nonvolatile memory 16 divided into areas A, B, and a transmitting unit 17 that transmits a response to the R/W 2.
In the nonvolatile memory 16, for example, when the IC card 10 is used as electronic money, available amount of money (remaining amount of money) is recorded. Note that, for ensuring atomicity of data recorded in the nonvolatile memory 16, the nonvolatile memory 16 is divided into areas A, B, and one is enabled and the other is disabled.
Further, data update is performed in this manner that data is read out from the enabled area and changed into new data (updated), and the changed (updated) data is written in the disabled area. Then, the area that has been disabled in which the changed (updated) data was written is enabled and the area that has been enabled is disabled.
A method of dividing a memory into plural areas and enabling one and disabling the others for ensuring atomicity of data recorded in the memory is related art as disclosed in JP-A-2005-235028, for example.
The selector 15 holds information indicating which of the-areas A, B is enabled (disabled), however, the nonvolatile memory 16 itself may hold the information.
Next, an operation of the IC card 10 will be described by taking the case where the IC card 10 is used as electronic money for example with reference to a flowchart in FIG. 2.
When a user of the IC card 10 purchases a product, if the user holds the IC card 10 over the R/W 2 installed in a store, a command is transmitted from the R/W 2 to the IC card 10. The command contains price information (e.g., \100) of the product.
In the IC card 10, at step S1, the receiving unit 12 receives the command from the R/W 2 and supplies the received command to the command processing unit 13.
At step S2, the command processing unit 13 reads out information of the remaining amount of money (e.g., \1,000) of electronic money from the enabled area of the areas A, B of the nonvolatile memory 16 via the updating unit 14 and the selector 15. Further, the command processing unit 13 subtracts the price of the purchased product from the read out remaining amount of money, generates information indicating the updated remaining amount of money (in this case, \900), and outputs it to the updating unit 14. Furthermore, the command processing unit 13 generates a response to the R/W 2 and outputs it to the transmitting unit 17. The response contains the information indicating the updated remaining amount of money.
Moreover, at step S3, the updating unit 14 overwrites (updates) the information indicating the updated remaining amount of money in the currently disabled area of the areas A, B of the nonvolatile memory 16 via the selector 15. After the overwriting is completed, the updating unit 14 controls the selector 15 to enable the area that has been disabled and in which rewriting was performed, and oppositely disable the area that has been enabled.
Then, at step S4, the command processing unit 13 transmits the response to the transmitting unit 17. This is the end of the operation of the IC card 10.
On the other hand, the R/W 2 recognizes the completion of payment by receiving the response from the IC card 10, and the operation of the R/W 2 for purchasing the product is ended.
However, in the above described operation of the IC card 10, for example, if the IC card 10 is moved away from the R/W 2 and power supply in the IC card 10 is disconnected after the processing at step S3 is ended and before the processing at step S4 is ended, a situation that the payment is completed at the IC card 10 side but the payment is not completed at the R/W 2 side may occur.
Here, the status that the payment is completed at the IC card 10 side refers to a status that the price of the product has been subtracted from the remaining amount of money, the information has been overwritten in one area of the nonvolatile memory 16, and the area has been enabled.
In the situation, a mechanism in which the payment processing is properly completed at both sides of the IC card 10 and the R/W 2 if the user holds the IC card 10 over the R/W 2 again is established. However, if the user does not execute this (hold the IC card 10 over the R/W 2 again), the user may not be able to obtain the product despite that the product price is taken from the remaining amount of money of the IC card 10.
Thus, it is desirable, in a noncontact communication system, to suppress the occurrence of the situation that the payment is completed at the IC card side but the payment is not completed at the R/W 2 side